<div class="panel-manage">
	<div class="navbar navbar-inverse">
		<div class="navbar-inner">		
		</div>
	</div>
	<div class="panel-space"></div>
	<table class="table table-striped table-list" style="margin:0 auto;">
		<thead>
			<tr style="background-color:brown; color:#fff;">
				<th width="3%"></th>
				<th width="7%"></th>
				<th width="70%">ชื่อร้าน</th>
				<th width="15%">ปรับปรุงล่าสุด</th>
				<th width="5%"></th>				
			</tr>
		</thead>
		<tbody>
			<?php for ($i=0; $i<count($data); $i++): ?>
				<tr>	
					<td><input type="checkbox" name="rc[]" /></td>				
					<td><img src="<?php print $data[$i]['CAF_IMG_L_FILENAME']; ?>" style="width:30px; height:30px;" /></td>					
					<td>
						<span class="block"><?php print $data[$i]['CAF_TITLE']; ?></span>
						<?php if ((strtotime($data[$i]['CAF_ULDATE_INFO']) <= strtotime($curr_date) && !empty($data[$i]['CAF_ULDATE_INFO']))): ?>
							<i class="icon-map-marker tooltips" data-toggle="tooltip" title="ปรับปรุงรายละเอียดใหม่"></i>							
						<?php endif; ?>
						
						<?php if ((strtotime($data[$i]['CAF_ULDATE_GAL']) <= strtotime($curr_date) && !empty($data[$i]['CAF_ULDATE_GAL']))): ?>
							<i class="icon-remove tooltips" data-toggle="tooltip" title="เพิ่มรูปภาพร้านใหม่"></i>
						<?php endif; ?>
						
						<?php if ((strtotime($data[$i]['CAF_ULDATE_PDT']) <= strtotime($curr_date) && !empty($data[$i]['CAF_ULDATE_PDT']))): ?>
							<i class="icon-align-right tooltips" data-toggle="tooltip" title="เพิ่มสินค้าใหม่"></i>
						<?php endif; ?>
						
						<?php if ((strtotime($data[$i]['CAF_ULDATE_CON']) <= strtotime($curr_date) && !empty($data[$i]['CAF_ULDATE_CON']))): ?>
							<i class="icon-align-left tooltips" data-toggle="tooltip" title="เพิ่มที่อยู่ใหม่"></i>
						<?php endif; ?>
					</td>
					<td>
						<small class="block"><?php print date('F d, Y', strtotime($data[$i]['CAF_LAST_ACTIVE'])); ?></small>
						<small class="block"><?php print date('H:i a', strtotime($data[$i]['CAF_LAST_ACTIVE'])); ?></small>
					</td>
					<td><button class="btn btn-mini btn-remove-fav" value="<?php print $data[$i]['CAF_TITLE']; ?>"><i class="icon-remove"></i></button></td>
				</tr>
			<?php endfor; ?>
		</tbody>				
	</table>
	<div class="pagination">
		<?php if ($page_count > 0){?>	
			<ul>
			    <li><a href="<?php print base_url() . 'member/favorite?p=1'; ?>">First</a></li>    
			    <?php for ($i=0; $i<$page_count; $i++) {?>
			      	<li><a href="<?php print base_url() . 'member/favorite?p=' . ($i+1); ?>"><?php print $i+1; ?></a></li>
			    <?php }?>
			    <li><a href="<?php print base_url() . 'member/favorite?p=' . $page_count; ?>">Last</a></li>
			</ul>
		<?php } ?>
	</div>
</div>
<script type="text/javascript">
	$(function(){
		$('.btn-remove-fav').click(function(){
			var me = $(this).parents('tr');
			$.post('<?php print base_url() . 'member/favorite/ajax_remove_favorite_cafe'; ?>', { c : $(this).val() }, function(output){
				switch (output.result){
					case true:
						me.fadeOut(1000);					
					break;
					case false:
						alert(output.message);					
					break;
					case -1:{
						alert(output.message);
						window.location.href = output.redirect_url;
					}
					break;	
				}					
			}, 'json');
		});
	});
</script>